<div class="action-dialog-model-fixed-body">
<div class="detailsBox">
<div class="openBox">
	<div class="detaiTab">
	 <form  name="module" id="sponsorForm" action="<@url value='/customerInfo/rest/update'/>" method ='post'   class="action-ajax-form action-ajax-form-valid action-ajax-form-confirm" action-ajax-form-confirm-message="确认提交">
		<table width="100%" cellspacing="0" cellpadding="0" border="0">
           <tbody>
   					<tr>
                        <td width="15%" align="right" class="bg">配偶姓： </td>
                        <td width="35%">${customer.user_surname} </td>
                        <td width="15%" align="right" class="bg">证件类型：</td>
                        <td>
							<#if "${customer.document_type}" ==	 "IDC" > 
							个人居民身份证
							<#elseif "${customer.document_type }" ==	 "PAS"> 
							个人护照
							<#elseif "${customer.document_type }" ==	 "GPAS"> 
							个人港澳居民来往内地通行证（香港）
							<#elseif "${customer.document_type }" ==	 "APAS"> 
							个人港澳居民来往内地通行证（澳门）
							<#elseif "${customer.document_type }" ==	 "OTH"> 
							其他
							</#if>
						</td>
                    </tr>
                     <tr>
                        <td width="15%" align="right" class="bg">配偶名：</td>
                        <td width="35%">${customer.user_name}</td>
                        <td width="15%" align="right" class="bg">证件号码:</td>
                        <td id="document_no2">${customer.document_no} </td>
                    </tr>
                      <td width="15%" align="right" class="bg">借款人姓拼音:</td>
					<td width="35%">
						<input type="hidden" name="customerType" value="1" />
						<input type="text" name="surnamePinyin" value="${customer.customerFamilyNamePy}"
						class="tabInp action-valid-field" data-action-valid-rule="required;" data-action-valid-msg-required="借款人姓拼音不能为空！"
								 autocomplete="off"/>
								 <span><font color="red">*</font></span>
								<span class="action-field-error" for="surnamePinyin" style="color: red;"></span>	
					</td>
					<td width="15%" align="right" class="bg">借款人名拼音:</td>
					<td width="35%">
						<input type="text" name="namePinyin" value="${customer.customerGivenNamePy}" 	
						class="tabInp action-valid-field" data-action-valid-rule="required;" data-action-valid-msg-required="借款人名拼音不能为空！"
								 autocomplete="off"/>
								 <span><font color="red">*</font></span>
								<span class="action-field-error" for="namePinyin" style="color: red;"></span>	
					</td>
                     <tr>
                     <!--
                       <td width="15%" align="right" class="bg">配偶姓名拼音：</td>
                       <td width="35%"><input type="text" name="userNamePinyin" value="${customer.user_name_pinyin}"/></td>
                      --> 
                       <td width="15%" align="right" class="bg">发证机构:</td>
                       <td>
                       <span class="action-form-field-group">
						        <input type="text"
						        	value="${customer.issuing_authority}"
									name="issuing_authority" class="tabInp action-valid-field"
									style="margin-bottom: 2px;"
									data-action-valid-rule="required;minlength:1;maxlength:10;reg:^.{1,10}$"
									data-action-valid-msg-reg="发证机构不能超过10个字"
									data-action-valid-msg-required="发证机构不能为空！"
									autocomplete="off" />
								<span><font color="red">*</font></span> 
								<span class="action-field-error" for="customerFamilyName" style="color: red;"></span>
					    </span> <br />
                       </td>
                    </tr>
                    
                    <tr>
                        <td width="15%" align="right" class="bg">性别 :</td>
                        <td id="sex2"></td>
                        <td width="15%" align="right" class="bg">证件有效期:</td>
                        <td>
                        <@date name="license_expiration_date"  value="${(customer.license_expiration_date?string('yyyy-MM-dd'))!''}" />
                        </td>
                    </tr>
                    
                     <tr>
						<td width="15%" align="right" class="bg">年龄:</td>
                        <td><span id="age2"></span>（岁）</td>
                        <td width="15%" align="right" class="bg">学历:</td>
                        <td>
                        	<select id="education_shouse" name="education" data="${customer.education}">
                        		<option value="MDS">初中及以下</option>
                        		<option value="SHS">高中/中专</option>
                        		<option value="UNV">大专</option>
                        		<option value="UDG">本科</option>
                        		<option value="GRT">研究生</option>
                        		<option value="OTH">其它</option>
                        		<option value="DTR">博士</option>
                        		<option value="MBA">MBA</option>
                        	</select>
                        
                        </td>
                    </tr>
                    
                    <tr>
                    	<td width="15%" align="right" class="bg">联系电话 :</td>
                        <td><input name="userPhone" id="userPhone" type="text" value="${customer.user_phone}"
                        			class="tabInp action-valid-field" maxlength="11"
									/><font color="red">*</font>
                        </td>
                        <td width="15%" align="right" class="bg">微信号 :</td>
                        <td>
                        <span class="action-form-field-group">
						        <input type="text" name="wechat"
						       		value="${customer.wechat}"
									class="tabInp action-valid-field"
									data-action-valid-rule="required;"
									data-action-valid-msg-required="微信号不能为空！" /> 
									<span><font color="red">*</font></span> 
									<span class="action-field-error" for="mobileNumber" style="color: red"></span>
						    </span> <br />	
                        </td>
                    </tr>
                    <tr>
                        <tr>
							<td width="15%" align="right" class="bg">户籍地址 :</td>
							<td colspan="3">
								<select id="select_provinceId_1" name="account_province" value="${customer.account_province}" onchange="provinceOnchange(1)"></select>&nbsp;&nbsp; 
	                    		<select id="select_areaId_1" name="account_city" value="${customer.account_city}" onchange="areaOnchange(1)"></select>&nbsp;&nbsp; 
	                    		<select id="select_cityId_1" name="account_county" value="${customer.account_county}" ></select>
	                    		<input type="text" name="permanent_residence" value="${customer.permanent_residence}">
							</td>
						</tr>
                        
                    </tr>
                    <tr>
                        <td width="15%" align="right" class="bg">工作单位:</td>
                        <td colspan="3">
                        <span class="action-form-field-group">
						        <input type="text" name="work_unit"
						       		value="${customer.work_unit}"
									class="tabInp action-valid-field"
									data-action-valid-rule="required;"
									data-action-valid-msg-required="工作单位不能为空！" /> 
									<span><font color="red">*</font></span> 
									<span class="action-field-error" for="mobileNumber" style="color: red"></span>
						    </span> <br />	
                        
                        </td>
                    </tr>
			   </tbody>
          </table>
          
          <input type="hidden" name="loan_user_id" value="${customer.loan_user_id} "/>
          <div class="clearfix" align="center"> 
                 <input type="submit" class="btn_auto_30 btn_blue mtb20" value="保存">
		  </div>
		</form>  
		
		
	</div> 
	</div>
</div>
</div>
 <@js>
	 if($('#education_shouse').attr('data')){
	 	$('#education_shouse').val($('#education_shouse').attr('data') );
	 }
	 
//省市区三级联动
	provinceLoad(1);
	provinceLoad(2);
	function provinceLoad(index){
		var provinceCode = $("#select_provinceId"+"_"+index).attr('value');
		$.ajax({
			type: "GET",
			url:"${crmUrl}/common/findProvinces",
			dataType:"jsonp",
			jsonp:"_callback",
			success:function(result){
					$("#select_provinceId"+"_"+index).empty();
					 $("#select_provinceId"+"_"+index).append("<option value=''>请选择</option>"); 
					 $("#select_areaId"+"_"+index).empty();
					 $("#select_areaId"+"_"+index).append("<option value=''>请选择</option>"); 
					 $("#select_cityId"+"_"+index).empty();
					 $("#select_cityId"+"_"+index).append("<option value=''>请选择</option>");   
					 $.each(result.data,function(key,value){
					 	if(provinceCode == value[0])
						    $("#select_provinceId"+"_"+index).append("<option value='"+value[0]+"' selected='selected'>"+value[1]+"</option>");   
						else
							$("#select_provinceId"+"_"+index).append("<option value='"+value[0]+"'>"+value[1]+"</option>");     
					 });
					 provinceOnchange(index,function(){
					 	 areaOnchange(index);
					 });
				    
		 		}
	 	});
     };
	
	
	function provinceOnchange(index,callback){
		var provinceCode = $("#select_provinceId"+"_"+index).val() || $("#select_provinceId"+"_"+index).attr('value');
		var areaCode = $("#select_areaId"+"_"+index).val() || $("#select_areaId"+"_"+index).attr('value');
		if(!provinceCode){
			 $("#select_areaId"+"_"+index).empty();
			 $("#select_areaId"+"_"+index).append("<option value=''>请选择</option>"); 
			 $("#select_cityId"+"_"+index).empty();
			 $("#select_cityId"+"_"+index).append("<option value=''>请选择</option>");   			
			 return true;
		}
		$.ajax({
			type: "GET",
			url:"${crmUrl}/common/findCityByProvinceCode",
			data:{provinceCode:provinceCode},
			dataType:"jsonp",
			jsonp:"_callback",
			success:function(result){
					 $("#select_areaId"+"_"+index).empty();
					 $("#select_areaId"+"_"+index).append("<option value=''>请选择</option>"); 
					 $("#select_cityId"+"_"+index).empty();
					 $("#select_cityId"+"_"+index).append("<option value=''>请选择</option>");   
					 $.each(result.data,function(key,value){
					 	if(areaCode == value[0])
						    $("#select_areaId"+"_"+index).append("<option value='"+value[0]+"' selected='selected'>"+value[1]+"</option>");   
						else
					 		$("#select_areaId"+"_"+index).append("<option value='"+value[0]+"'>"+value[1]+"</option>");   
						 
					 });
					 callback &&　callback();
		 		}
	 	});
     }
	      
	 function areaOnchange(index){
		var areaCode = $("#select_areaId"+"_"+index).val() || $("#select_areaId"+"_"+index).attr('value');
		var cityCode = $("#select_cityId"+"_"+index).val() || $("#select_cityId"+"_"+index).attr('value');
		if(!areaCode){
			$("#select_cityId"+"_"+index).empty();
		    $("#select_cityId"+"_"+index).append("<option value=''>请选择</option>");   
			return true;
		}
		$.ajax({
			type: "GET",
			url:"${crmUrl}/common/findDistrictByCityCode",
			data:{cityCode:areaCode},
			dataType:"jsonp",
			jsonp:"_callback",
			success:function(result){
				 $("#select_cityId"+"_"+index).empty();
				 $("#select_cityId"+"_"+index).append("<option value=''>请选择</option>");   
				 $.each(result.data,function(key,value){
				 	if(cityCode == value[0])
					    $("#select_cityId"+"_"+index).append("<option value='"+value[0]+"' selected='selected'>"+value[1]+"</option>");   
					else
						$("#select_cityId"+"_"+index).append("<option value='"+value[0]+"'>"+value[1]+"</option>");   
				 });
			 }
	 	});
	}
	
	
	
	
	
		 var document_no = $('#document_no2').text();
		 $('#age2').text(getAge(document_no));
		 $('#sex2').text(getSex(document_no) == 'M'? '男':'女 ');
		 
		 //根据身份证信息获取年龄
		function getSex(UUserCard){
			//获取出生日期
			UUserCard.substring(6, 10) + "-" + UUserCard.substring(10, 12) + "-" + UUserCard.substring(12, 14);
			//获取性别
			if (parseInt(UUserCard.substr(16, 1)) % 2 == 1) {
				//alert("男");
			  	return 'M';
			} else {
				//alert("女");
				return 'F';
			}
		}
		
		  function getAge(UUserCard){
			var myDate = new Date();
			var month = myDate.getMonth() + 1;
			var day = myDate.getDate();
			var age = myDate.getFullYear() - UUserCard.substring(6, 10) - 1;
			if (UUserCard.substring(10, 12) < month || UUserCard.substring(10, 12) == month && UUserCard.substring(12, 14) <= day) {
				age++;
			}
			//alert(age);
			return age;
	    }
</@js>
<@jsRender/>
